package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Attendance;
import com.example.demo.entity.Vacation;
import org.apache.ibatis.annotations.*;

import java.util.Date;

@Mapper
public interface VacationMapper extends BaseMapper<Vacation> {
    // 新增请假信息
    @Insert("INSERT INTO vacation(number, id, name, departmentid, department, time, type, reason,timeover,status) VALUES (#{number}, #{id}, #{name}, #{departmentid}, #{department}, #{time}, #{type}, #{reason}, #{timeover}, #{status})")
    void insert(
            @Param("number") int number,
            @Param("id") int id,
            @Param("name") String name,
            @Param("departmentid") int departmentid,
            @Param("department") String department,
            @Param("time") Date time,
            @Param("type") String type,
            @Param("reason") String reason,
            @Param("timeover") Date timeover,
            @Param("status") String status
            );

    // 删除请假信息
    @Delete("DELETE FROM vacation WHERE number = #{number}")
    int deleteByNumber(int number);

    // 更新请假信息
    @Update("UPDATE vacation SET number = #{number}, id = #{id}, name = #{name}, departmentid = #{departmentid}, department = #{department}, time = #{time}, type = #{type}, reason = #{reason}, timeover = #{timeover}, status = #{status} WHERE number = #{number}")
    int update(Vacation vacation);

    // 根据编号查询请假信息
    @Select("SELECT number, id, name, departmentid, department,time, type, reason, timeover, status FROM vacation WHERE number = #{number}")
    Vacation findByNumber(int number);
}